package com.jluzh10.learning.service.Impl;

import com.jluzh10.learning.dao.ReplyMapper;
import com.jluzh10.learning.domain.Reply;
import com.jluzh10.learning.service.ReplyService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * @author cj
 * @date 6/1/2019
 */
@Service
@Transactional
public class ReplyServiceImpl implements ReplyService {

    private final ReplyMapper replyMapper;

    @Autowired
    public ReplyServiceImpl(ReplyMapper replyMapper) {
        this.replyMapper = replyMapper;
    }


    /**
     * 查询某条回答下的所有评论
     * @param answerId
     * @return
     */
    public List<Reply> searchReplies(Integer answerId) {

        return replyMapper.selectAllReplies(answerId);
    }

    /**
     * 插入一条回复
     * @param reply
     * @return
     */
    @Override
    public int addReply(Reply reply) {

        return replyMapper.insertSelective(reply);
    }
}
